const Koa = require('koa');
const path = require('path');
const static = require('koa-static');
const koaBody = require('koa-body');
const api = require('./api');
const compress = require('koa-compress');
const staticCache = require('koa-static-cache')
const redirectHtml = require('./middleware/redirectHtml');
// const authorization = require('./middleware/authorization');
const args = require('minimist')(process.argv.slice(2));

const app = new Koa();

app.use(compress({ threshold: 1024 }));
app.use(koaBody({ multipart: true }));
// app.use(authorization);
app.use(api.routes());
app.use(staticCache(path.join(__dirname, '../../web/build')));
app.use(static(path.join(__dirname, '../../web/build')));
app.use(redirectHtml);
app.listen('4100');

console.log(`http://localhost:4100`);
console.log('-----------------');